package com.recommend.service.admin.impl;

import java.util.List;

import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.recommend.domain.MovieDomain;
import com.recommend.persistence.MovieDomainMapper;
import com.recommend.service.MovieService;

/**
 * Created by lw.
 */
@Service
@Transactional
public class MovieServiceImpl implements MovieService{
    private final static Logger logger = org.slf4j.LoggerFactory.getLogger(LoginServiceImpl.class);

    @Autowired
    private MovieDomainMapper movieDomainMapper;

    @Override
    public List<MovieDomain> getAllMovie(){
        List<MovieDomain> movieDomains = movieDomainMapper.selectAll();
        logger.info("==============================movie count: {}===========", movieDomains.size());
        return movieDomains;
    }

    @Override
    public List<MovieDomain> searchMovie(MovieDomain movieDomain){
        return movieDomainMapper.selectListSelective(movieDomain);
    }

    @Override
    public MovieDomain getMovie(int movieId){
        MovieDomain movieDomain = movieDomainMapper.selectByPrimaryKey(movieId);
        logger.debug("=======================movie_id:{}=====movie: {}, movie:{}", movieId, movieDomain.getMovieId(), movieDomain);
        return movieDomain;
    }

    @Override
     public int addMovie(MovieDomain movieDomain){
        return movieDomainMapper.insertSelective(movieDomain);
    }

    @Override
    public int updateMovie(MovieDomain movieDomain){
        return movieDomainMapper.updateByPrimaryKeySelective(movieDomain);
    }



}
